package com.nacos.demo.config;

import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.exception.NacosException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author hh
 * @since 2023/4/2
 */
@Configuration
public class NacosConfig {

    @Autowired
    private NacosDiscoveryProperties nacosDiscoveryProperties;

    @Bean
    public ConfigService configService() throws NacosException {
        return NacosFactory.createConfigService(nacosDiscoveryProperties.getNacosProperties());
    }

}
